<?php defined('InNcPHP') or exit('Access Invalid!');?>
<style>
    .show { display: block; }
    .hide { display: none; }
    .layui-layer-title{color: red;}
</style>
<script type="text/javascript" src="<?php echo RESOURCE_URL;?>/common/jquery-ui/jquery.ui.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_URL;?>/common/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_URL;?>/common/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <h3>提现列表</h3>
            <?php echo $output['top_link'];?>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <!--  搜索表单  -->
    <form method="get" name="formSearch" id="formSearch">
        <input type="hidden" value="pd_cash" name="act">
        <input type="hidden" value="index" name="op">
        <table class="tb-type1 noborder search">
            <tbody>
            <tr>
                <th><label> 退款编号</label></th>
                <td><input type="text" name="search_sn" value="<?php echo $output['search']['search_sn']; ?>" class="txt"></td>
                <th><label> 手机号</label></th>
                <td><input type="text" name="pdc_user_name" value="<?php echo $output['search']['pdc_user_name']; ?>" class="txt"></td>
            </tr>
            <tr>
                <th><label> 处理状态</label></th>
                <td>
                    <select name="search_status">
                        <option value=""><?php echo $lang['nc_please_choose'];?>...</option>
                        <?php if (is_array($output['status'])): ?>
                            <?php foreach ($output['status'] as $k => $v): ?>
                                <option value="<?php echo $k; ?>" <?php echo $output['search']['search_status'] == $k ? 'selected' : ''; ?>><?php echo $v; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                </td>
                <th><label> <?php echo '收款方式';?></label></th>
                <td>
                    <select name="pay_type">
                        <option value=""><?php echo $lang['nc_please_choose'];?>...</option>
                        <?php if (is_array($output['pay_type'])): ?>
                            <?php foreach ($output['pay_type'] as $k => $v): ?>
                                <option value="<?php echo $k; ?>" <?php echo $output['search']['pay_type'] == $k ? 'selected' : ''; ?>><?php echo $v; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                </td>
                <td>
                    <a href="javascript:void(0);" onclick="$('#formSearch').submit();" class="btn-search"></a>
                    <?php if ($output['search']['search_sn'] || $output['search']['search_phone'] ||$output['search']['search_stime'] || $output['search']['search_etime'] || $output['search']['search_merchant'] || $output['search']['pay_type'] || $output['search']['search_status']): ?>
                        <a href="index.php?act=pd_cash&op=index" class="btns "><span><?php echo $lang['nc_cancel_search']?></span></a>
                    <?php endif; ?>
                </td>
            </tr>
            </tbody>
        </table>
    </form>

    <a class="m-btn blue-stripe mini <?php echo $_GET['search_status']==''?'checked':'' ?> " onclick="parent.openItem('index,pd_cash,member');" href="#">全部</a>
    <a class="m-btn green-stripe mini <?php echo $_GET['search_status']=='0'?'checked':'' ?>" onclick="parent.openItem('index,pd_cash,member,search_status=0');"  href="#">待处理</a>
    <a class="m-btn yellow-stripe mini <?php echo $_GET['search_status']==1?'checked':'' ?>" onclick="parent.openItem('index,pd_cash,member,search_status=1');"  href="#">已同意</a>
    <a class="m-btn red-stripe mini  <?php echo $_GET['search_status']==2?'checked':'' ?> " onclick="parent.openItem('index,pd_cash,member,search_status=2');" href="#">已拒绝</a>


    <div style="text-align:right;"><a class="btns" target="_blank" href="index.php?<?php echo $_SERVER['QUERY_STRING'];?>&op=export"><span><?php echo $lang['nc_export'];?>Excel</span></a></div>
    <!--  显示列表  -->
    <table class="table tb-type2 nobdb">
        <thead>
        <tr class="thead">
            <th>提现编号</th>
            <th class="align-center">会员</th>
            <th class="align-center">收款类型</th>
            <th>收款账号</th>
            <th>提现金额</th>
            <th>实际到账金额</th>
            <th>费率</th>
            <th class="align-center">处理状态</th>
            <th class="align-center">发起时间</th>
            <th class="align-center"><?php echo $lang['nc_handle'];?></th>
        </tr>
        <tbody>
        <?php if(!empty($output['cash_list']) && is_array($output['cash_list'])){ ?>
            <?php foreach($output['cash_list'] as $k => $v){ ?>
                <tr class="hover member">
                    <td><?php echo $v['pdc_sn']; ?></td>
                    <td class="align-center" ><?php echo $v['member_name']; ?></td>
                    <td class="align-center"><?php echo $output['pay_type'][$v['pdc_type']]; ?></td>
                    <td> <?php echo $v['pdc_number']; ?></td>
                    <td> <?php echo $v['pdc_amount']; ?></td>
                    <td> <?php echo $v['real_amount']; ?></td>
                    <td> <?php echo $v['tariff'].'%'; ?> </td>
                    <td class="align-center"><?php echo $output['status'][$v['pdc_status']]; ?></td>
                    <td class="align-center"><?php echo date('Y-m-d H:i:s',$v['pdc_add_time']); ?></td>
                    <td class="align-center">
                        <a href="###" onclick="check_edit(<?php echo $v['pdc_id']; ?>, $(this));"><?php echo $v['pdc_status']==0?'审核':'查看'; ?></a>
                    </td>
                </tr>
            <?php } ?>
        <?php }else { ?>
            <tr class="no_data">
                <td colspan="11"><?php echo $lang['nc_no_record']?></td>
            </tr>
        <?php } ?>
        </tbody>
        <tfoot class="tfoot">
        <?php if(!empty($output['cash_list']) && is_array($output['cash_list'])){ ?>
            <tr>
                <td colspan="16">
                    <div class="pagination"> <?php echo $output['page'];?> </div>
                </td>
            </tr>
        <?php } ?>
        </tfoot>
    </table>
    <!-- 审核表单 -->
    <form id="refund_edit" method="post" class="hide">
        <input type="hidden" name="pdc_id">
        <table class="table tb-type2">
            <tbody>
            <!-- 日期 -->
            <tr>
                <td colspan="2" class="required"><label class="validation">会员名称:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform member_name"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">收款账号:</label><span class="pay_type">(退款至微信)</span></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform pdc_number"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">收款人姓名:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform pdc_user_name"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">身份证:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform member_idcard"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">提现金额:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform pdc_amount"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">手续费率:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform tariff"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">实际到账金额:</label>(扣除手续费)</td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform real_amount"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">处理备注:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                    <textarea id="reason" name="reason" class="txt" style="width:70%;height: 100px;"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation">审核意见:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                    <select id="status" name="status" class="class-select">
                        <option value="1">同意</option>
                        <option value="2">拒绝</option>
                    </select>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="2"><a href="JavaScript:void(0);" class="btn" id="editSubmit"><span><?php echo $lang['nc_update'];?></span></a></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script>
    //开始日期
    $('#search_stime').datepicker({
        dateFormat: 'yy-mm-dd',
        onClose: function(selectedDate) {
            $("#search_etime").datepicker("option", "minDate", selectedDate);
        }
    });
    //结束日期
    $('#search_etime').datepicker({
        dateFormat: 'yy-mm-dd',
        onClose: function(selectedDate) {
            $("#search_stime").datepicker("option", "maxDate", selectedDate);
        }
    });

    //编辑的表单
    var editForm = $('#refund_edit');
    function check_edit(Id,obj)
    {
        $("#reason").val('');
        $.post('index.php?act=pd_cash&op=ajax_cash_info', {pdc_id: Id}, function (data) {
            editForm.find('input[name="pdc_id"]').val(data.pdc_id);
            editForm.find(".member_name").text(data.member_name);
            editForm.find(".pdc_number").text(data.pdc_number);
            editForm.find(".pdc_user_name").text(data.pdc_user_name);
            editForm.find(".member_idcard").text(data.member_idcard);
            editForm.find(".pdc_amount").text(data.pdc_amount);
            editForm.find("#reason").val(data.reason);
            editForm.find(".tariff").text(parseFloat(data.tariff) * 100 /parseFloat(100)+'%');
            editForm.find(".real_amount").text(data.real_amount);
            if(data.pdc_type==1){
                editForm.find(".pay_type").text('(微信账号)');
            }else if(data.pdc_type==2){
                editForm.find(".pay_type").text('(支付宝账号)');
            }
            if(data.pdc_status!=0){
                $("#editSubmit").hide();
            }else{
                $("#editSubmit").show();
            }
            layer.open({
                type: 1,
                title: '审核提现订单',
                area: ['700px', '410px'],
                content: editForm,
                cancel: function () {
                    $('label.error').hide();
                    //editForm.find('input.error').removeClass('error');
                }
            });
        }, 'json');
    }

    //提交编辑表单
    $("#editSubmit").click(function(){
        if($("#reason").val()==''){
            layer.alert('处理备注不能为空');
            return;
        }
        layer.confirm('确认您的审核操作？', {
            btn: ['<?php echo $lang['nc_yes']; ?>', '<?php echo $lang['nc_no']; ?>']
        },function(index){
            $.post('index.php?act=pd_cash&op=audit_cash',editForm.serialize(),function(data){
                if(data.res){
                    layer.alert('<?php echo $lang['nc_common_update_succ']; ?>', function () {
                        location.reload();
                    });
                }else{
                    layer.alert('<?php echo $lang['nc_common_update_fail']; ?>');
                }
            },'json');
            layer.close(index);
        })
    })


</script>
